/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _OLA_PAL_TIME_H_
#define _OLA_PAL_TIME_H_

typedef enum {
    OLA_TIME_SYNC_FAILED    = -1,
    OLA_TIME_SYNC_OK        = 0,
    OLA_TIME_SYNC_ASYN      = 1,
} OlaTimeSyncErr;

/*
 * 功能: 时间同步回调函数
 * 参数: timestamp，UNIX时间戳
 */
typedef void (*OlaTimeSyncAsynCallbak)(unsigned long long timestamp);

/*
 * 功能: 尝试获取UNIX时间戳
 * 参数: (1) timestamp，出参，获取到的UNIX时间戳
 *       (2) cb，时间同步回调函数
 * 返回: OLA_TIME_SYNC_FAILED，表示时间同步失败
 *       OLA_TIME_SYNC_OK，表示同步成功，同时返回有效的UNIX时间戳
 *       OLA_TIME_SYNC_ASYN，时间异步处理，并在时间同步成功后通过OlaPalTimeInit注册的回调函数返回UNIX时间戳
 * 注意: OLA SDK会在设备联网后调用该接口尝试同步时间，该接口实现请勿阻塞
 */
int OlaTimeSync(unsigned long long *timestamp, OlaTimeSyncAsynCallbak cb);

#endif /* _OLA_PAL_TIME_H_ */